﻿using Models;
using System.Diagnostics;
using System.IO;
using System.Windows.Controls;

namespace WorkPieceDataCapture
{
    public static class GlobalClass
    {
        public static Dictionary<string, int> dic_ExportColumnRelation = new Dictionary<string, int>()  //导出明细时字段与Excel中所在列的对应关系
        {
            //总成与主体
            {"iID",0},
            {"ZC_SerialNo",1},
            {"ZC_Model",2},
            {"ZC_Time",3},
            {"ZC_ProduceMode",4},
            {"ZC_LaserNo",5},
            {"ZC_Result",6},
            {"FLJ_ZT_Model",7},
            {"FLJ_ZT_Material",8},
            //一次圈
            {"FLJ_YCQ_Model",9},
            {"FLJ_YCQ_Material",10},
            {"FLJ_YCQ_Result",11},
            //隔离环
            {"FLJ_GLH_Model",12},
            {"FLJ_GLH_Material",13},
            {"FLJ_GLH_Result",14},
            //二次圈
            {"FLJ_ECQ_Model",15},
            {"FLJ_ECQ_Material",16},
            {"FLJ_ECQ_Result",17},
            //安全环
            {"FLJ_KZH_Model",18},
            {"FLJ_KZH_Material",19},
            {"FLJ_KZH_Upper",20},
            {"FLJ_KZH_Lower",21},
            {"FLJ_KZH_Value",22},
            {"FLJ_KZH_Result",23},
            {"FLJ_KZH_PressureResult",24},
            //锁扣
            {"FLJ_SK_Model",25},
            {"FLJ_SK_Material",26},
            {"FLJ_SK_Result",27},
            //内密
            {"FLJ_NM_Result",28},
            //外密
            {"FLJ_WM_Model",29},
            {"FLJ_WM_Material",30},
            {"FLJ_WM_Result",31},
            //内密气密
            {"JCY_QM_Program",32},
            {"JCY_QM_Pressure",33},
            {"JCY_QM_PressureUnit",34},
            {"JCY_QM_Leak",35},
            {"JCY_QM_LeakUnit",36},
            {"JCY_QM_Result",37},
            //壳体气密
            {"JCY_KTQM_Program",38},
            {"JCY_KTQM_Pressure",39},
            {"JCY_KTQM_PressureUnit",40},
            {"JCY_KTQM_Leak",41},
            {"JCY_KTQM_LeakUnit",42},
            {"JCY_KTQM_Result",43},
            // 打码检测（新增）
            {"ZC_DM_ScanText",44},
            {"ZC_DM_Result",45},
            //登录人员
            {"LoginUser",46}
        };
        public static Dictionary<string, int> dic_ExportDetailRelation = new Dictionary<string, int>()  //导出明细时字段与Excel中所在行的对应关系
        {
            {"ZC_SerialNo",2}, // 总成设备标识码
            {"ZC_Model",3}, // 总成型号
            {"ZC_Time",4}, // 总成生产时间
            {"ZC_ProduceMode",5}, // 生产模式
            {"ZC_LaserNo",6}, // 总成激光打码编码
            {"ZC_Result",7}, // 总成综合结果
            {"FLJ_ZT_Model",8}, // 分零件：主体型号码
            {"FLJ_ZT_Material",9}, // 分零件：主体物料编码

            {"FLJ_YCQ_Model",10}, // 分零件：一次圈型号码
            {"FLJ_YCQ_Material",11}, // 分零件：一次圈物料编码
            {"FLJ_YCQ_Photo",12}, // 分零件：一次圈相机存储路径
            {"FLJ_YCQ_Result",13}, // 分零件：一次圈检测结果

            {"FLJ_GLH_Model",14}, // 分零件：隔离环型号码
            {"FLJ_GLH_Material",15}, // 分零件：隔离环物料编码
            {"FLJ_GLH_Photo",16}, // 分零件：隔离环相机存储路径
            {"FLJ_GLH_Result",17}, // 分零件：隔离环检测结果

             {"FLJ_ECQ_Model",18}, // 分零件：二次圈型号码
             {"FLJ_ECQ_Material",19}, // 分零件：二次圈物料编码
             {"FLJ_ECQ_Photo",20}, // 分零件：二次圈相机存储路径
             {"FLJ_ECQ_Result",21}, // 分零件：二次圈检测结果

            {"FLJ_KZH_Model",22}, // 分零件：安全环型号码
            {"FLJ_KZH_Material",23}, // 分零件：安全环物料编码
            {"FLJ_KZH_Upper",24}, // 分零件：安全环位移检测参数上限
            {"FLJ_KZH_Lower",25}, // 分零件：安全环位移检测参数下限
            {"FLJ_KZH_Value",26}, // 分零件：安全环检测位移偏差
            {"FLJ_KZH_Result",27}, // 分零件：安全环检测结果
            {"FLJ_KZH_PressureResult",28}, // 分零件：安全环压力检测结果

            {"FLJ_SK_Model",29}, // 分零件：锁扣型号码
            {"FLJ_SK_Material",30}, // 分零件：锁扣物料编码
            {"FLJ_SK_Photo",31}, // 分零件：锁扣相机存储路径
            {"FLJ_SK_Result",32}, // 分零件：锁扣检测结果

            {"FLJ_NM_Photo",33}, // 分零件：内密相机存储路径
            {"FLJ_NM_Result",34}, // 分零件：内密检测结果

            {"FLJ_WM_Model",35 },// 分零件：外密型号码
            {"FLJ_WM_Material",36 },// 分零件：外密物料编码
            {"FLJ_WM_Photo1",37 },// 分零件：外密相机1路径
            {"FLJ_WM_Photo2",38 },// 分零件：外密相机2路径
            {"FLJ_WM_Result",39 },// 分零件：外密检测结果

            {"JCY_QM_Program",40}, // 检测仪：气密检测程序号
            {"JCY_QM_Pressure",41}, // 检测仪：气密检测压力值
            {"JCY_QM_PressureUnit",42}, // 检测仪：内密气密压力单位
            {"JCY_QM_Leak",43}, // 检测仪：气密检测泄漏值
            {"JCY_QM_LeakUnit",44}, // 检测仪：内密气密泄漏单位
            {"JCY_QM_Result",45}, // 检测仪：气密检测结果

            {"JCY_KTQM_Program",46}, // 检测仪：壳体气密检测程序号
            {"JCY_KTQM_Pressure",47}, // 检测仪：壳体气密检测压力值
            {"JCY_KTQM_PressureUnit",48}, // 检测仪：壳体气密压力单位
            {"JCY_KTQM_Leak",49}, // 检测仪：壳体气密检测泄漏值
            {"JCY_KTQM_LeakUnit",50}, // 检测仪：壳体气密泄漏单位
            {"JCY_KTQM_Result",51}, // 检测仪：壳体气密检测结果

            {"FLJ_SL_Photo",52 },// 分零件：上料相机路径
            {"FLJ_SL_Photo2",53 },// 分零件：上料相机路径2

            // 打码检测（新增明细导出行）
            {"ZC_DM_ScanText",54 }, // 打码扫码字符
            {"ZC_DM_Photo",55 }, // 打码检测存储路径
            {"ZC_DM_Result",56 }, // 打码检测结果

            {"LoginUser",57 },// 登录人员
        };
        public static Dictionary<string, int> dic_ExportColumnRelation_PointCheck = new Dictionary<string, int>()  //导出明细时字段与Excel中所在列的对应关系
        {
             //总成                                                   
            {"iID",0},//序号
            {"EquipmentName",1},//设备名称
            {"Operator",2},//处理人员
            {"CheckTime",3},//登录时间 
            {"ZC_SeriesNo",4},//注销时间
            {"Result",5},//综合检测结果
        };
        public static int WindowWidth = 0;
        public static int WindowHeight = 0;

        public static FuncResult<string> openFile(string strPath)
        {
            var result = new FuncResult<string>();
            try
            {
                if (File.Exists(strPath))
                {
                    Process.Start("explorer.exe", $"/open,\"{strPath}\"");
                    result.bSuccess = true;
                }
                else
                {
                    result.bSuccess = false;
                    result.strMsg = "文件不存在！";
                }
            }
            catch (Exception ex)
            {
                result.bSuccess = false;
                result.strMsg = "文件打开失败！\n" + ex.Message;
            }
            return result;
        }
    }
}
